#include <bits/stdc++.h>
using namespace std;

void solve() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    vector<int> a(n + 1);
    for(int i = n - 1; i >= 0; i--) {
        a[i] = a[i + 1] + (s[i] - '0');
    }
    string ans;
    int c = 0;
    for(int i = 0; i < n; i++) {
        c += a[i];
        ans += (c % 10 + '0');
        c /= 10;
    }
    ans += (c + '0');
    while(ans.back() == '0'){
        ans.pop_back();
    }
    reverse(ans.begin(), ans.end());
    cout << ans << '\n';
}

int main() {
    int t;
    cin >> t;
    while(t--) solve();
    return 0;
}